package classes.web;

import org.junit.Test;

import java.io.*;
import java.net.Socket;

public class TCPClientTest {
    @Test
    public void test() {
        Socket localhost = null;
        try {
            localhost = new Socket("localhost", 9999);  //主动连接
            OutputStream outputStream = localhost.getOutputStream();
            InputStream inputStream = localhost.getInputStream();
            outputStream.write("1".getBytes());


        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (localhost != null) {
                try {
                    localhost.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
